package router

import (
	docs "orm_gin/docs"
	"orm_gin/router/account"
	"orm_gin/router/goods"
	"orm_gin/router/user"
	"orm_gin/router/vlogs"
	"orm_gin/utools/cors"
	"orm_gin/utools/jwttool"

	"github.com/gin-gonic/gin"
	swaggerFiles "github.com/swaggo/files"
	ginSwagger "github.com/swaggo/gin-swagger"
)

func InitRouter() *gin.Engine {
	r := gin.Default()

	r.Use(cors.Cors()) // 用于全部跨域

	docs.SwaggerInfo.BasePath = "/" //根路由,这一行不写找不到docs文档
	r.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler))

	// 账户登录
	account.AccountApi(r)
	//goods
	goods.GoodsApi(r, jwttool.JWTAuthMiddleware())
	// vlogs  修正auth 的状态,增加 鉴权
	vlogs.VlogsApi(r, jwttool.JWTAuthMiddleware())
	// 用户模块
	user.UserApi(r, jwttool.JWTAuthMiddleware())

	return r
}
